﻿
@{
    ViewBag.Title = "EFamily";
    var family = ViewBag.Member as FamilyTree.Entity.FamilyInfoEntity;
}

<section class="content-header" style="padding-top:30px;">
     
</section>
<section class="content">
    <form class="form-horizontal" method="post" id="formMain">
        <div class="box box-solid">
            <div class="box-body">
                <div class="row">

                    <input type="hidden" id="FamilyInfoId" name="FamilyInfoId" value="@family.FamilyInfoId" />
                    <input type="hidden" id="ParentId" name="ParentId" value="@family.ParentId" />
                    <input type="hidden" id="CreateTime" name="CreateTime" value="@family.CreateTime" />
                    <input type="hidden" id="IsDelete" name="IsDelete" value="@family.IsDelete" />

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="FamilyName" class="col-sm-3 control-label">名称</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" id="FamilyName" name="FamilyName" value="@family.FamilyName" maxlength="100">
                        </div>
                    </div>

                    <div class="form-group col-md-6 col-sm-12">
                        <label for="Profile" class="col-sm-3 control-label">简称</label>
                        <div class="col-sm-9">
                            <textarea class="form-control" rows="3" cols="20" id="Profile" name="Profile" maxlength="500">@family.Profile</textarea>
                        </div>
                    </div>

                </div>

            </div>
            <div class="box-footer">
                <div class="box-footer" style="float: right; padding-right: 200px; padding-top: 20px;">
                    <span class="btn btn-primary " id="btnSave">确 定</span>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a class="btn btn-primary" href="@Url.Action("Index","FamilyInfo")">返 回</a>
                </div>
            </div>
        </div>
    </form>
</section>



<script type="text/javascript">

    var type = '@ViewBag.Type';

    $('#btnSave').on("click", function () {
        var jsonData = { "MemberId": 0, "FamilyName": "", "FamilyInfoId": 0, "Profile": "", "IsDelete": 0, "ParentId": 0,  "CreateTime": "" };

        jsonData.FamilyInfoId = $('#FamilyInfoId').val();
        jsonData.FamilyName = $('#FamilyName').val();
        jsonData.IsDelete = $('#IsDelete').val();
        jsonData.CreateTime = $('#CreateTime').val();
        jsonData.RelationName = $('#sltRelationName').val();
        jsonData.ParentId = $('#ParentId').val();
        jsonData.Profile = $('#Profile').val();

        $.post('@Url.Action("EditFamily", "FamilyInfo")', jsonData, function (response) {
            // 请求成功时的回调函数
            var result = JSON.stringify(response);
            if (result == '1') {
                var url ='@Url.Action("index", "FamilyInfo")';
                window.location.href = url + '?edit=9';
            } else {
                alert('保存失败');
            }
        }, 'json');

    });
</script>
